import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import '../color.dart';
import '../text_style.dart';

class DoubleDialog extends Dialog {
  final VoidCallback? yesCallback;
  final VoidCallback? noCallback;
  final String? content;
  final String? title;
  final String? name;
  final String? yesStr;
  final String? noStr;
  final String? tail;
  //是否包含输入框
  final bool? isEdit;
  final TextEditingController? controller;

  DoubleDialog(
    this.content, {
    Key? key,
    this.yesCallback,
    this.noCallback,
    this.yesStr,
    this.noStr,
    this.name,
    this.tail,
    this.title,
    this.isEdit,
    this.controller,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Material(
      color: Colors.transparent,
      child: Center(
        child: Container(
          margin: EdgeInsets.only(left: 20.w,right: 20.w,bottom: 30.w),
          decoration: const BoxDecoration(
            image: DecorationImage(
              image: AssetImage("assets/user_cancel_alert.png"),
              fit: BoxFit.cover,
            ),
          ),
          constraints: BoxConstraints(minHeight: 255.w),
          child: Column(
            mainAxisSize: MainAxisSize.min,
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              Container(
                margin: EdgeInsets.only(bottom: 19.w,top: 34.w),
                child: Text(
                  title ?? '确定注销账户？',
                  style: TextStyleUtils.style000000(
                      fontSize: 18.sp, fontWeight: FontWeight.w500),
                ),
              ),
              Container(
                margin: EdgeInsets.symmetric(horizontal: 24.w),
                child: RichText(
                  textAlign: TextAlign.center,
                  text: TextSpan(
                    children: [
                      TextSpan(
                        text: content,
                        style: TextStyleUtils.style000000(fontSize: 15.sp),
                      ),
                      TextSpan(
                          text: name ?? '',
                          style: TextStyleUtils.styleF65247(fontSize: 14.sp)),
                      TextSpan(
                        text: tail ?? '',
                        style: TextStyleUtils.style4d4d4d(fontSize: 14.sp),
                      ),
                    ],
                  ),
                ),
              ),
              Visibility(
                visible: isEdit ?? false,
                child: Container(
                  margin: EdgeInsets.symmetric(horizontal: 24.w),
                  height: 38.w,
                  decoration: BoxDecoration(
                    border: Border.all(color: ColorManager.colorF2F2F2,width: 1.w),
                    borderRadius: BorderRadius.all(Radius.circular(4.w)),
                  ),
                  alignment: Alignment.center,
                  child: TextField(
                    decoration: const InputDecoration(
                      border: OutlineInputBorder(//保证TextField输入内容居中
                        borderSide: BorderSide(
                          color: Colors.transparent,
                        ),
                      ),
                      enabledBorder: OutlineInputBorder(
                        borderSide: BorderSide(
                          color: Colors.transparent,
                        ),
                      ),
                      disabledBorder: OutlineInputBorder(
                        borderSide: BorderSide(
                          color: Colors.transparent,
                        ),
                      ),
                      focusedBorder: OutlineInputBorder(
                        borderSide: BorderSide(
                          color: Colors.transparent,
                        ),
                      ),
                      contentPadding: EdgeInsets.zero
                    ),
                    controller: controller,
                    textAlign: TextAlign.center,
                    style: TextStyleUtils.style2A2A2A(),
                  ),
                ),
              ),
              SizedBox(height: 24.w),
              Container(
                margin: EdgeInsets.symmetric(horizontal: 24.w),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Expanded(
                      child: InkWell(
                        onTap: () => yesCallback!(),
                        child: Container(
                          height: 40.w,
                          alignment: Alignment.center,
                          decoration: BoxDecoration(
                            border: Border.all(color: ColorManager.colorD5D5D5,width: 0.5.w),
                            borderRadius: BorderRadius.all(Radius.circular(20.w)),
                          ),
                          child: Text(
                            yesStr ?? '确定',
                            style: TextStyleUtils.style000000(
                              fontSize: 16.sp,
                            ),
                          ),
                        ),
                      ),
                    ),
                    SizedBox(width: 17.w,),
                    Expanded(
                      child: InkWell(
                        onTap: noCallback ?? () => Navigator.pop(context),
                        child: Container(
                          height: 40.w,
                          decoration: BoxDecoration(
                            border: Border.all(color: ColorManager.colorD5D5D5,width: 0.5.w),
                            borderRadius: BorderRadius.all(Radius.circular(20.w)),
                            color: ColorManager.colorD93C3A
                          ),
                          alignment: Alignment.center,
                          child: Text(
                            noStr ?? '取消',
                            style: TextStyleUtils.styleFFFFFF(
                              fontSize: 16.sp,
                            ),
                          ),
                        ),
                      ),
                    ),
                  ],
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
